//
//  Copyright (C) 1998-2007 J. Andrew McLaughlin
//  Copyright (C) 2009 Vadim Ushakov
// 
//  This program is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License as published by the Free
//  Software Foundation; either version 2 of the License, or (at your option)
//  any later version.
// 
//  This program is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
//  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
//  for more details.
//  
//  You should have received a copy of the GNU General Public License along
//  with this program; if not, write to the Free Software Foundation, Inc.,
//  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//

#if !defined(_KERNELWINDOWSTDCOMPONENTINTERNALS_H)

#include "kernelWindow.h"
#include "kernelWindowComponent.h"


typedef volatile struct {
	borderType type;

} kernelWindowBorder;

typedef volatile struct {
	const char label[WINDOW_MAX_LABEL_LENGTH];
	image buttonImage;
	int state;

} kernelWindowButton;

typedef volatile struct {
	char *text;
	int selected;

} kernelWindowCheckbox;

typedef volatile struct {
	const char name[WINDOW_MAX_LABEL_LENGTH];
	kernelWindowComponent **components;
	int maxComponents;
	int numComponents;
	int numColumns;
	int numRows;

	// Functions
	void (*drawGrid) (kernelWindowComponent *);

} kernelWindowContainer;

// An icon image component
typedef volatile struct {
	int borderDrawn;
	int selected;
	image iconImage;
	char label[2][WINDOW_MAX_LABEL_LENGTH];
	int labelLines;
	int labelWidth;
	char command[MAX_PATH_NAME_LENGTH];

} kernelWindowIcon;

// An image as a window component
typedef volatile struct {
	image image;
	drawMode mode;

} kernelWindowImage;

typedef kernelWindowImage kernelWindowCanvas;

typedef volatile struct {
	windowListType type;
	int columns;
	int rows;
	int itemWidth;
	int itemHeight;
	int selectMultiple;
	int multiColumn;
	int selectedItem;
	int firstVisibleRow;
	int itemRows;
	kernelWindowComponent *container;
	kernelWindowComponent *scrollBar;

} kernelWindowList;

typedef volatile struct {
	windowListType type;
	listItemParameters params;
	kernelWindowComponent *icon;
	int selected;

} kernelWindowListItem;

typedef volatile struct {
	kernelGraphicBuffer buffer;
	kernelWindowComponent *container;

} kernelWindowMenu;

typedef volatile struct {
	kernelWindowComponent *visibleMenu;
	kernelWindowComponent *container;

} kernelWindowMenuBar;

typedef kernelWindowListItem kernelWindowMenuItem;

typedef kernelTextArea kernelWindowPasswordField;

typedef volatile struct {
	int progressPercent;
	int sliderWidth;

} kernelWindowProgressBar;

typedef volatile struct {
	char *text;
	int numItems;
	int selectedItem;

} kernelWindowRadioButton;

typedef volatile struct {
	scrollBarType type;
	scrollBarState state;
	int sliderX;
	int sliderY;
	int sliderWidth;
	int sliderHeight;

} kernelWindowScrollBar;

typedef kernelWindowScrollBar kernelWindowSlider;

typedef volatile struct {
	kernelTextArea *area;
	int areaWidth;
	kernelWindowComponent *scrollBar;

} kernelWindowTextArea;

// A text area as a text field component
typedef kernelTextArea kernelWindowTextField;

typedef volatile struct {
	char *text_orig;
	int   text_orig_length;
	char *text;
	int lines;
} kernelWindowTextLabel;

typedef volatile struct {
	kernelWindowComponent *minimizeButton;
	kernelWindowComponent *closeButton;

} kernelWindowTitleBar;


#ifdef DEBUG
static inline const char *componentTypeString(kernelWindowObjectType type)
{
	// Return a string representation of a window object type.
	switch (type)
	{
	case genericComponentType:
		return ("genericComponentType");
	case borderComponentType:
		return ("borderComponentType");
	case buttonComponentType:
		return ("buttonComponentType");
	case canvasComponentType:
		return ("canvasComponentType");
	case checkboxComponentType:
		return ("checkboxComponentType");
	case containerComponentType:
		return ("containerComponentType");
	case iconComponentType:
		return ("iconComponentType");
	case imageComponentType:
		return ("imageComponentType");
	case listComponentType:
		return ("listComponentType");
	case listItemComponentType:
		return ("listItemComponentType");
	case menuComponentType:
		return ("menuComponentType");
	case menuBarComponentType:
		return ("menuBarComponentType");
	case progressBarComponentType:
		return ("progressBarComponentType");
	case radioButtonComponentType:
		return ("radioButtonComponentType");
	case scrollBarComponentType:
		return ("scrollBarComponentType");
	case sliderComponentType:
		return ("sliderComponentType");
	case sysContainerComponentType:
		return ("sysContainerComponentType");
	case textAreaComponentType:
		return ("textAreaComponentType");
	case textLabelComponentType:
		return ("textLabelComponentType");
	case titleBarComponentType:
		return ("titleBarComponentType");
	case windowType:
		return ("windowType");
	default:
		return ("unknown");
	}
}
#endif

#define _KERNELWINDOWSTDCOMPONENTINTERNALS_H
#endif
